import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
function _resolve(dir) {
  return path.resolve(__dirname, dir);
}

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": _resolve("src"),
    },
  },
  server: {
    proxy: {
      "/gateway": {
        target: process.env.VITE_API_URL, // 使用环境变量
        changeOrigin: true, // 是否改变源地址
        rewrite: (path) => path.replace(/^\/api/, ""), // 重写路径
      },
    },
  },
});
